import { Column } from "typeorm";
import { UpdateDateColumn, ValueTransformer } from "typeorm";

import { PrimaryGeneratedColumn } from "typeorm";
import { Entity } from "typeorm";

@Entity()
export class Article {
    @PrimaryGeneratedColumn()
    id: number

    @Column({
        type: "longtext",
        comment: "文章具体内容",
        transformer: {
            //  获取的时候 走from
            from(value) {
                console.log("from ", value);
                console.dir(this);
                return value
            },

            //  设置的时候走to 
            to(value) {
                console.log("to ", value);
                return value
            }
        }
    })
    content: string


    @UpdateDateColumn()
    updateTime: Date;

    @Column({ name: "name" })
    private _name: string

    // @Column()
    set name(name) {
        this._name = name + "---hllang"
    }

    get name(): string {
        return this._name
    }

}